<template>
	<view>
		<Header></Header>
		<UserInfoCard :userInfo='userInfo'></UserInfoCard>
		<FunctionList :functionCardimag='functionCardimag'></FunctionList>
		<view class="loginOut" @click="loginOutBtn" v-if="$store.state.isLogin">
			<view class="outText">
					<text>退出登录</text>
			</view>
		</view>
		<text>\n\n\n\n\n\n</text>
		<view class="zaudio" v-show="paused !== true ">
			<my-zaudio theme="theme3" ref='a'></my-zaudio>
		</view>
	</view>

</template>

<script>
	import {mapGetters} from 'vuex'
	import Header from './comments/Header.vue'
	import UserInfoCard from './comments/UserInfoCard.vue'
	import FunctionList from './comments/FunctionList.vue'
	export default {
		components: {
			Header,
			UserInfoCard,
			FunctionList
		},
		data() {
			return {
				userInfo: {},
				functionCardimag: ['../../static/home/functionCardImage/1.png',
				'../../static/home/functionCardImage/2.png',
				'../../static/home/functionCardImage/3.png',
				'../../static/home/functionCardImage/4.png',
				'../../static/home/functionCardImage/5.png',
				'../../static/home/functionCardImage/6.png',
				'../../static/home/functionCardImage/7.png',
				'../../static/home/functionCardImage/8.png',
				]
			}
		},
		onLoad() {
			this.getUserInfo()
			
			// this.getUserNumberInfo()
		},
		methods: {
			
			async getUserInfo() {
				let a = uni.getStorageSync('userInfo')
				
				if (a) {
					this.$store.state.isLogin = true
					this.userInfo = JSON.parse(a)
				const res = await this.$request({
					url: '/user/detail',
					data: {
						uid: this.userInfo.userId
					}
				})
				this.userInfo = res.data
				
				}else{
					this.$store.state.isLogin = false
				}
			},
			// async getUserNumberInfo(){
			// 	const res = await this.$request({
			// 		url:'/user/account',
			// 		data:{						uid: this.userInfo.userId}
			// 	})
			// 	console.log( res)
			// 	console.log('获取账号信息')
				
			// }
			loginOutBtn(){
				uni.showModal({
				    title: '提示',
				    content: '这是一个模态弹窗',
				    success: function (res) {
				        if (res.confirm) {
				           uni.removeStorage({key:'userInfo'});
				           uni.removeStorage({key:'userid'});
				           uni.removeStorage({key:'cookietoken'});
						   const res = this.$cookies.keys()
						   console.log(res)
						   res.forEach(item => {
						   	$cookies.remove(item)
						   })
						   location.reload()
						   uni.navigateTo({
						   	url: '/pages/login/login',
						   	fail( res) {
						   		console.log(res)
						   		console.log(0)
						   	}
						   })
				        } else if (res.cancel) {
				            console.log('用户取消退出登录');
				        }
				    }
				});
			},
		
		},
		computed:{
			...mapGetters(['audiolist', 'playinfo', 'paused'])
		}

	}
</script>

<style scoped>
	.outText{
		text-align: center;
		border-radius: 20upx;
		background-color: #ff5500;
		height: 80upx; 
		width: 90%;
		margin-left: 5%;
	}
.loginOut{
	color: #000000; font-size: 40upx;
}


</style>
